/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.camelspit.preludetoarmageddon.entity;

/**
 * Base Entity is the base for creatures, players and items.
 * Every entity has a name and an ID number. The ID number is
 * how you will access each entity.
 *
 * @author DMK
 */
public class BaseEntity {
    //Class Declarations
    private int entityId;
    private String name;

    public BaseEntity() {
    
    }


    public String getName() {return name;}
    public void setName(String name) {this.name = name;}

    public int getID() {return entityId;}
    public void setID(int entityId) {this.entityId = entityId;}
    public void setID(String stringId) {
        int temp = Integer.parseInt(stringId);
        this.entityId = temp;
    }

    /**
     * fullMatch() returns true if name and compName match, ignoring
     * the case (PLAyEr equals player equals pLayER);
     * @param compName
     * @return
     */
    public boolean fullMatch(String compName) {
        return name.equalsIgnoreCase(compName);
    }
    /**
     * Returns true if compName length is 0. This allows the player
     * to enter nothing and get the first entity in the room.
     * <p>Returns true if compName begins name,
     * <p>For example. If name == Player and compName == Pla , then
     * match() returns true. However if compName == layer, it does not
     * because name doesn't begin with layer.
     * <p>Lastly, returns true if compName begins the second or third
     * word in the name. If name == Great Player and compName == play,
     * match() returns true.
     * @param compName
     * @return
     */
    public boolean match(String compName) {
        if(compName.length() == 0) {
            return true;
        } else if(compName.charAt(0) == ' ') {
            return name.contains(' ' + compName);
        } else
            return name.startsWith(compName);
    }
}
